Shroud Part 3 Puzzle Solver

(Taken directly from Lights out puzzle solver and modified)
(Secondly Taken From http://www.perfectweb.org/ddo/solver/vale_puzzle.html and modified)